package search;

public class BinarySearch {
    public static void main(String[] args) {
        int[] nums = { 1, 3, 6, 10, 30, 68 };
        int target = 10;
        int min = 0;
        int max = nums.length - 1;
        int ret = search(nums, target, min, max);
        System.out.println(ret);
    }

    private static int search(int[] nums, int target, int min, int max) {
        System.out.println(min + "：" + max);
        if (min <= max) {
            int mid = (min + max) / 2;
            System.out.println(mid);
            if (nums[mid] == target) {
                return mid;
            } else if (nums[mid] < target) {
                return search(nums, target, mid + 1, max);
            } else if (nums[mid] > target) {
                return search(nums, target, min, mid - 1);
            }
        }

        return -1;
    }
}
